using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Data.OracleClient;
using System.Linq;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class VWPACK
    {
        public static readonly VWPACK SWPACK = new VWPACK();
        public DataRow NWPACK(MessageInfo msg)
        {
            LOADWPACK(msg);
            DataRow dwData = TBMain.NewRow();
            double value = 0;
            SetUpNewRow(ref dwData);
            #region=========
            dwData["WPMANDANT"] = app.Mandant;
            dwData["WPLIEFSCH"] = msg.LIEFSCH;
            dwData["WPPACKNR"] = "0001";
            GetPOS();
            dwData["WPPACKPOS"] = Helper.Right("0000" + LINE, 4);
            dwData["WPAUFTYP"] = msg.AUFTYP;
            dwData["WPAUFKRS"] = msg.KRS;
            dwData["WPAUFLFD"] = msg.LFD;
            dwData["WPAUFPOS"] = msg.POS;
            dwData["WPTEILNR"] = "0001";
            dwData["WPRWKRS"] = msg.RWKRS;
            dwData["WPRWLFD"] = msg.RWLFD;
            dwData["WPPOS"] = msg.RWPOS;
            dwData["WPLO"] = msg.LO;
            dwData["WPLB"] = msg.LB;
            dwData["WPAUFBKZ"] = "N";
            dwData["WPDPART"] = msg.P4;
            dwData["WPSTKNR"] = msg.STKNR;
            dwData["WPWAKZ"] = msg.WAKZ;
            dwData["WPART"] = msg.ART;
            dwData["WPVAR"] = msg.VAR;
            dwData["WPDESS"] = msg.DESS;
            dwData["WPCOLORIT"] = msg.COLORIT;
            dwData["WPFARBE"] = msg.FARBE;
            dwData["WPBESCHICH"] = msg.BESCHICH;
            dwData["WPZUSTAND"] = msg.ZUSTAND;
            dwData["WPISTKLG"] = msg.P1;
            value = Convert.ToDouble(msg.P2);
            dwData["WPIGEW"] = value;
            dwData["WPKGNET"] = value / 10;// "4680";
            dwData["WPKGBRUT"] = value / 10; //"4690"; 
            value = Convert.ToDouble(msg.P3);
            dwData["WPIBRT"] = value * 100;
            dwData["WPIBRTFV"] = value * 100;
            dwData["WPIBRTFB"] = value * 100;
            dwData["WPNEUB"] = app.User;
            dwData["WPNEUD"] = date;
            dwData["WPAENB"] = app.User;
            dwData["WPAEND"] = date;
            #endregion
            TBMain.Rows.InsertAt(dwData, 0);
            InsertWPACK(dwData, app.company);
            return dwData;
        }
        double LINE = 0;
        private void GetPOS()
        {
            var qData = from XD in SetProd.Tables[TableName].AsEnumerable()
                        group XD by new
                        {
                            WPLIEFSCH = XD["WPLIEFSCH"].ToString(),
                            WPPACKNR = XD["WPPACKNR"].ToString(),
                        }
                            into g
                            select new
                            {
                                KEY = g.Key,
                                LPOS = g.Max(XD => Convert.ToDouble(XD["WPPACKPOS"].ToString())),
                            };
            foreach (var XD in qData)
            {
                LINE = XD.LPOS;
            }
            LINE++;
        }
        string LIEFSCH = "";
        public void LOADWPACK(MessageInfo msg)
        { 
            if (LIEFSCH != msg.LIEFSCH)
            {
                LIEFSCH = msg.LIEFSCH;
                dwData = TBMain.NewRow();
                dwData["WPMANDANT"] = app.Mandant;
                dwData["WPLIEFSCH"] = LIEFSCH;
                SResult = QueryWPACK(dwData, 2);
                MergeData(SResult, true, true);
            } 
        }
    }

    public partial class VWPACK
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "TST":
                default:
                    #region=========
                    dwReturn["WPMANDANT"] = app.Mandant;
                    dwReturn["WPLIEFSCH"] = "00000000";
                    dwReturn["WPPACKNR"] = "0000";
                    dwReturn["WPPACKPOS"] = "0000";
                    dwReturn["WPAUFTYP"] = " ";
                    dwReturn["WPAUFKRS"] = "  ";
                    dwReturn["WPAUFLFD"] = "000000";
                    dwReturn["WPAUFPOS"] = "000";
                    dwReturn["WPTEILNR"] = "0000";
                    dwReturn["WPRWKRS"] = "  ";
                    dwReturn["WPRWLFD"] = "000000";
                    dwReturn["WPPOS"] = "0000";
                    dwReturn["WPLO"] = "01";
                    dwReturn["WPLB"] = "KO";
                    dwReturn["WPAUFBKZ"] = "N";
                    dwReturn["WPDPART"] = "           ";
                    dwReturn["WPDPART2"] = "           ";
                    dwReturn["WPSTKNR"] = "            ";
                    dwReturn["WPKUNDNR"] = "00000000";
                    dwReturn["WPWERK"] = "   ";
                    dwReturn["WPABT"] = "   ";
                    dwReturn["WPWAKZ"] = " ";
                    dwReturn["WPART"] = "                    ";
                    dwReturn["WPVAR"] = "  ";
                    dwReturn["WPDESS"] = "          ";
                    dwReturn["WPCOLORIT"] = "          ";
                    dwReturn["WPFARBE"] = "1         ";
                    dwReturn["WPBESCHICH"] = "          ";
                    dwReturn["WPZUSTAND"] = "    ";
                    dwReturn["WPFARBN"] = "  ";
                    dwReturn["WPISTKLG"] = "0";
                    dwReturn["WPIGEW"] = "0";
                    dwReturn["WPIBRT"] = "0";
                    dwReturn["WPBRGEW"] = "0";
                    dwReturn["WPDM"] = "0";
                    dwReturn["WPVOL"] = "0";
                    dwReturn["WPIGEWKZ"] = " ";
                    dwReturn["WPIANZ"] = "0";
                    dwReturn["WPMABRT1"] = "0";
                    dwReturn["WPMASTKLG1"] = "0";
                    dwReturn["WPMABRT2"] = "0";
                    dwReturn["WPMASTKLG2"] = "0";
                    dwReturn["WPMABRT3"] = "0";
                    dwReturn["WPMASTKLG3"] = "0";
                    dwReturn["WPMABRT4"] = "0";
                    dwReturn["WPMASTKLG4"] = "0";
                    dwReturn["WPMABRT5"] = "0";
                    dwReturn["WPMASTKLG5"] = "0";
                    dwReturn["WPTARA"] = "10";
                    dwReturn["WPKGNET"] = "4680";
                    dwReturn["WPKGBRUT"] = "4690";
                    dwReturn["WPAUFMSL"] = "  ";
                    dwReturn["WPPACKTYP"] = "01  ";
                    dwReturn["WPURLAND"] = "CN ";
                    dwReturn["WPGEBNR"] = "        ";
                    dwReturn["WPGEBPOS"] = "000";
                    dwReturn["WPRE"] = "0";
                    dwReturn["WPRENETTO"] = "0";
                    dwReturn["WPREVGUET"] = "0";
                    dwReturn["WPRS"] = "0";
                    dwReturn["WPRSNETTO"] = "0";
                    dwReturn["WPRSVGUET"] = "0";
                    dwReturn["WPVE"] = "0";
                    dwReturn["WPVENETTO"] = "0";
                    dwReturn["WPVEVGUET"] = "0";
                    dwReturn["WPVS"] = "0";
                    dwReturn["WPVSNETTO"] = "0";
                    dwReturn["WPVSVGUET"] = "0";
                    dwReturn["WPANZTEILE"] = "0";
                    dwReturn["WPVERSION"] = "0";
                    dwReturn["WPTAX"] = "   ";
                    dwReturn["WPZENSUR"] = "1";
                    dwReturn["WPZENSURKZ"] = "A";
                    dwReturn["WPUBRT"] = "0";
                    dwReturn["WPZUSAM"] = "  ";
                    dwReturn["WPMAART"] = " ";
                    dwReturn["WPROLLR"] = "I";
                    dwReturn["WPAUFMPOS"] = "0000";
                    dwReturn["WPKONFKZ"] = " ";
                    dwReturn["WPKETTELN"] = " ";
                    dwReturn["WPSHSTK1"] = "0";
                    dwReturn["WPSHBRT1"] = "0";
                    dwReturn["WPSHSTKLG1"] = "0";
                    dwReturn["WPSHSTK2"] = "0";
                    dwReturn["WPSHBRT2"] = "0";
                    dwReturn["WPSHSTKLG2"] = "0";
                    dwReturn["WPSHSTK3"] = "0";
                    dwReturn["WPSHBRT3"] = "0";
                    dwReturn["WPSHSTKLG3"] = "0";
                    dwReturn["WPSHSTK4"] = "0";
                    dwReturn["WPSHBRT4"] = "0";
                    dwReturn["WPSHSTKLG4"] = "0";
                    dwReturn["WPSHSTK5"] = "0";
                    dwReturn["WPSHBRT5"] = "0";
                    dwReturn["WPSHSTKLG5"] = "0";
                    dwReturn["WPSTKNRK"] = "            ";
                    dwReturn["WPAUSFFRB"] = "100";
                    dwReturn["WPAUSFGRI"] = "100";
                    dwReturn["WPAUSFQUAL"] = "100";
                    dwReturn["WPQUALST"] = " ";
                    dwReturn["WPQPKT"] = "0";
                    dwReturn["WPQPKTH"] = "0";
                    dwReturn["WPQPKTL"] = "0";
                    dwReturn["WPQPKTLH"] = "0";
                    dwReturn["WPISTKLGFA"] = "0";
                    dwReturn["WPISTKLGF"] = "0";
                    dwReturn["WPFRTWSKZ"] = " ";
                    dwReturn["WPLTPOS"] = "0";
                    dwReturn["WPILGFBT"] = "0";
                    dwReturn["WPILGRBT"] = "0";
                    dwReturn["WPIBRTFV"] = "0";
                    dwReturn["WPIBRTFB"] = "0";
                    dwReturn["WPFEUCHTE"] = "0";
                    dwReturn["WPKDPART"] = "          ";
                    dwReturn["WPBEM"] = "               ";
                    dwReturn["WPTXSCHL"] = "  ";
                    dwReturn["WPREFSCHL"] = "   ";
                    dwReturn["WPRSFSCHL"] = "   ";
                    dwReturn["WPVEFSCHL"] = "   ";
                    dwReturn["WPVSFSCHL"] = "   ";
                    dwReturn["WPRAMPE"] = " ";
                    dwReturn["WPFILLER"] = "0004001                                                                                               ";
                    dwReturn["WPAENZL"] = "0";
                    dwReturn["WPNEUB"] = "        ";
                    dwReturn["WPNEUD"] = "0";
                    dwReturn["WPAENB"] = "        ";
                    dwReturn["WPAEND"] = "0";
                    #endregion
                    break;
                case "JLT":
                    #region========
                    dwReturn["WPMANDANT"] = app.Mandant;
                    dwReturn["WPLIEFSCH"] = "00000000";
                    dwReturn["WPPACKNR"] = "0000";
                    dwReturn["WPPACKPOS"] = "0000";
                    dwReturn["WPAUFTYP"] = "K";
                    dwReturn["WPAUFKRS"] = "  ";
                    dwReturn["WPAUFLFD"] = "000000";
                    dwReturn["WPAUFPOS"] = "000";
                    dwReturn["WPTEILNR"] = "0000";
                    dwReturn["WPRWKRS"] = "  ";
                    dwReturn["WPRWLFD"] = "000000";
                    dwReturn["WPPOS"] = "0000";
                    dwReturn["WPLO"] = "01";
                    dwReturn["WPLB"] = "  ";
                    dwReturn["WPAUFBKZ"] = "N";
                    dwReturn["WPDPART"] = "           ";
                    dwReturn["WPDPART2"] = "           ";
                    dwReturn["WPSTKNR"] = "            ";
                    dwReturn["WPKUNDNR"] = "00000000";
                    dwReturn["WPWERK"] = "   ";
                    dwReturn["WPABT"] = "   ";
                    dwReturn["WPWAKZ"] = "F";
                    dwReturn["WPART"] = "                    ";
                    dwReturn["WPVAR"] = "  ";
                    dwReturn["WPDESS"] = "          ";
                    dwReturn["WPCOLORIT"] = "          ";
                    dwReturn["WPFARBE"] = "          ";
                    dwReturn["WPBESCHICH"] = "          ";
                    dwReturn["WPZUSTAND"] = "    ";
                    dwReturn["WPFARBN"] = "  ";
                    dwReturn["WPISTKLG"] = "0";
                    dwReturn["WPIGEW"] = "0";
                    dwReturn["WPIBRT"] = "0";
                    dwReturn["WPBRGEW"] = "0";
                    dwReturn["WPDM"] = "0";
                    dwReturn["WPVOL"] = "0";
                    dwReturn["WPIGEWKZ"] = " ";
                    dwReturn["WPIANZ"] = "0";
                    dwReturn["WPMABRT1"] = "0";
                    dwReturn["WPMASTKLG1"] = "0";
                    dwReturn["WPMABRT2"] = "0";
                    dwReturn["WPMASTKLG2"] = "0";
                    dwReturn["WPMABRT3"] = "0";
                    dwReturn["WPMASTKLG3"] = "0";
                    dwReturn["WPMABRT4"] = "0";
                    dwReturn["WPMASTKLG4"] = "0";
                    dwReturn["WPMABRT5"] = "0";
                    dwReturn["WPMASTKLG5"] = "0";
                    dwReturn["WPTARA"] = "1";
                    dwReturn["WPKGNET"] = "0";
                    dwReturn["WPKGBRUT"] = "0";
                    dwReturn["WPAUFMSL"] = "  ";
                    dwReturn["WPPACKTYP"] = "    ";
                    dwReturn["WPURLAND"] = "   ";
                    dwReturn["WPGEBNR"] = "        ";
                    dwReturn["WPGEBPOS"] = "000";
                    dwReturn["WPRE"] = "0";
                    dwReturn["WPRENETTO"] = "0";
                    dwReturn["WPREVGUET"] = "0";
                    dwReturn["WPRS"] = "0";
                    dwReturn["WPRSNETTO"] = "0";
                    dwReturn["WPRSVGUET"] = "0";
                    dwReturn["WPVE"] = "0";
                    dwReturn["WPVENETTO"] = "0";
                    dwReturn["WPVEVGUET"] = "0";
                    dwReturn["WPVS"] = "0";
                    dwReturn["WPVSNETTO"] = "0";
                    dwReturn["WPVSVGUET"] = "0";
                    dwReturn["WPANZTEILE"] = "0";
                    dwReturn["WPVERSION"] = "0";
                    dwReturn["WPTAX"] = "   ";
                    dwReturn["WPZENSUR"] = "1";
                    dwReturn["WPZENSURKZ"] = "A";
                    dwReturn["WPUBRT"] = "0";
                    dwReturn["WPZUSAM"] = "  ";
                    dwReturn["WPMAART"] = " ";
                    dwReturn["WPROLLR"] = "I";
                    dwReturn["WPAUFMPOS"] = "0000";
                    dwReturn["WPKONFKZ"] = " ";
                    dwReturn["WPKETTELN"] = " ";
                    dwReturn["WPSHSTK1"] = "0";
                    dwReturn["WPSHBRT1"] = "0";
                    dwReturn["WPSHSTKLG1"] = "0";
                    dwReturn["WPSHSTK2"] = "0";
                    dwReturn["WPSHBRT2"] = "0";
                    dwReturn["WPSHSTKLG2"] = "0";
                    dwReturn["WPSHSTK3"] = "0";
                    dwReturn["WPSHBRT3"] = "0";
                    dwReturn["WPSHSTKLG3"] = "0";
                    dwReturn["WPSHSTK4"] = "0";
                    dwReturn["WPSHBRT4"] = "0";
                    dwReturn["WPSHSTKLG4"] = "0";
                    dwReturn["WPSHSTK5"] = "0";
                    dwReturn["WPSHBRT5"] = "0";
                    dwReturn["WPSHSTKLG5"] = "0";
                    dwReturn["WPSTKNRK"] = "            ";
                    dwReturn["WPAUSFFRB"] = "100";
                    dwReturn["WPAUSFGRI"] = "100";
                    dwReturn["WPAUSFQUAL"] = "100";
                    dwReturn["WPQUALST"] = " ";
                    dwReturn["WPQPKT"] = "0";
                    dwReturn["WPQPKTH"] = "0";
                    dwReturn["WPQPKTL"] = "0";
                    dwReturn["WPQPKTLH"] = "0";
                    dwReturn["WPISTKLGFA"] = "0";
                    dwReturn["WPISTKLGF"] = "0";
                    dwReturn["WPFRTWSKZ"] = " ";
                    dwReturn["WPLTPOS"] = "0";
                    dwReturn["WPILGFBT"] = "0";
                    dwReturn["WPILGRBT"] = "0";
                    dwReturn["WPIBRTFV"] = "0";
                    dwReturn["WPIBRTFB"] = "0";
                    dwReturn["WPFEUCHTE"] = "0";
                    dwReturn["WPKDPART"] = "          ";
                    dwReturn["WPBEM"] = "               ";
                    dwReturn["WPTXSCHL"] = "  ";
                    dwReturn["WPREFSCHL"] = "   ";
                    dwReturn["WPRSFSCHL"] = "   ";
                    dwReturn["WPVEFSCHL"] = "   ";
                    dwReturn["WPVSFSCHL"] = "   ";
                    dwReturn["WPRAMPE"] = " ";
                    dwReturn["WPFILLER"] = "                                                                                                      ";
                    dwReturn["WPAENZL"] = "0";
                    dwReturn["WPNEUB"] = "        ";
                    dwReturn["WPNEUD"] = "0";
                    dwReturn["WPAENB"] = "        ";
                    dwReturn["WPAEND"] = "0";

                    #endregion
                    break;
            }
        }
        public void InsertWPACK(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            or1 = OracleDB.CreateCommand();
            switch (ITXDBVERSION)
            {
                case "YGR":
                case "YCC":
                case "TST":
                default:
                    or1.CommandText = "INSERT INTO WPACK ( WPMANDANT,WPLIEFSCH,WPPACKNR,WPPACKPOS,WPAUFTYP,WPAUFKRS,WPAUFLFD,WPAUFPOS,WPTEILNR,WPRWKRS,WPRWLFD,WPPOS,WPLO,WPLB,WPAUFBKZ,WPDPART,WPDPART2,WPSTKNR,WPKUNDNR,WPWERK,WPABT,WPWAKZ,WPART,WPVAR,WPDESS,WPCOLORIT,WPFARBE,WPBESCHICH,WPZUSTAND,WPFARBN,WPISTKLG,WPIGEW,WPIBRT,WPBRGEW,WPDM,WPVOL,WPIGEWKZ,WPIANZ,WPMABRT1,WPMASTKLG1,WPMABRT2,WPMASTKLG2,WPMABRT3,WPMASTKLG3,WPMABRT4,WPMASTKLG4,WPMABRT5,WPMASTKLG5,WPTARA,WPKGNET,WPKGBRUT,WPAUFMSL,WPPACKTYP,WPURLAND,WPGEBNR,WPGEBPOS,WPRE,WPRENETTO,WPREVGUET,WPRS,WPRSNETTO,WPRSVGUET,WPVE,WPVENETTO,WPVEVGUET,WPVS,WPVSNETTO,WPVSVGUET,WPANZTEILE,WPVERSION,WPTAX,WPZENSUR,WPZENSURKZ,WPUBRT,WPZUSAM,WPMAART,WPROLLR,WPAUFMPOS,WPKONFKZ,WPKET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:,:WPRSVGUET:,:WPVE:,:WPVENETTO:,:WPVEVGUET:,:WPVS:,:WPVSNETTO:,:WPVSVGUET:,:WPANZTEILE:,:WPVERSION:,:WPTAX:,:WPZENSUR:,:WPZENSURKZ:,:WPUBRT:,:WPZUSAM:,:WPMAART:,:WPROLLR:,:WPAUFMPOS:,:WPKONFKZ:,:WPKETTELN:,:WPSHSTK1:,:WPSHBRT1:,:WPSHSTKLG1:,:WPSHSTK2:,:WPSHBRT2:,:WPSHSTKLG2:,:WPSHSTK3:,:WPSHBRT3:,:WPSHSTKLG3:,:WPSHSTK4:,:WPSHBRT4:,:WPSHSTKLG4:,:WPSHSTK5:,:WPSHBRT5:,:WPSHSTKLG5:,:WPSTKNRK:,:WPAUSFFRB:,:WPAUSFGRI:,:WPAUSFQUAL:,:WPQUALST:,:WPQPKT:,:WPQPKTH:,:WPQPKTL:,:WPQPKTLH:,:WPISTKLGFA:,:WPISTKLGF:,:WPFRTWSKZ:,:WPLTPOS:,:WPILGFBT:,:WPILGRBT:,:WPIBRTFV:,:WPIBRTFB:,:WPFEUCHTE:,:WPKDPART:,:WPBEM:,:WPTXSCHL:,:WPREFSCHL:,:WPRSFSCHL:,:WPVEFSCHL:,:WPVSFSCHL:,:WPRAMPE:,:WPFILLER:,:WPAENZL:,:WPNEUB:,:WPNEUD:,:WPAENB:,:WPAEND:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                case "JLT":
                    or1.CommandText = "INSERT INTO WPACK ( WPMANDANT,WPLIEFSCH,WPPACKNR,WPPACKPOS,WPAUFTYP,WPAUFKRS,WPAUFLFD,WPAUFPOS,WPTEILNR,WPRWKRS,WPRWLFD,WPPOS,WPLO,WPLB,WPAUFBKZ,WPDPART,WPDPART2,WPSTKNR,WPKUNDNR,WPWERK,WPABT,WPWAKZ,WPART,WPVAR,WPDESS,WPCOLORIT,WPFARBE,WPBESCHICH,WPZUSTAND,WPFARBN,WPISTKLG,WPIGEW,WPIBRT,WP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WPAENZL:,:WPNEUB:,:WPNEUD:,:WPAENB:,:WPAEND:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }
            Connect2Proxy(or1);
        }
        public DataSet QueryWPACK(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 0:
                    or1.CommandText = "SELECT * FROM WPACK WHERE  ROWNUM<2 ";
                    break;
                case 1:
                    or1.CommandText = "SELECT * FROM WPACK "
                    + " WHERE WPMANDANT=:WPMANDANT: AND  WPLIEFSCH=:WPLIEFSCH: AND WPPACKNR=:WPPACKNR: AND WPPACKPOS=:WPPACKPOS: ";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM WPACK "
                    + " WHERE WPMANDANT=:WPMANDANT: AND  WPLIEFSCH=:WPLIEFSCH:  ";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
                case 99:
                    or1.CommandText = "SELECT * FROM WPACK  WHERE ROWNUM<50";
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "WPACK";
            Return = Result;
            return Return;
        }
        public void DeleteWPACK(DataRow dwData, int option = 1)
        {

            OracleCommand or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "DELETE FROM WPACK   WHERE  VAKBMANDANT=:VAKBMANDANT AND VAKBKOLL=:VAKBKOLL AND VAKBART =:VAKBART AND VAKBFARBE=:VAKBFARBE AND VAKBKUNDNR=:VAKBKUNDNR";
                    or1.Parameters.Add("VAKBMANDANT", OracleType.NVarChar).Value = dwData["VAKBMANDANT"].ToString();
                    or1.Parameters.Add("VAKBKOLL", OracleType.NVarChar).Value = dwData["VAKBKOLL"].ToString();
                    or1.Parameters.Add("VAKBART", OracleType.NVarChar).Value = dwData["VAKBART"].ToString();
                    or1.Parameters.Add("VAKBFARBE", OracleType.NVarChar).Value = dwData["VAKBFARBE"].ToString();
                    or1.Parameters.Add("VAKBKUNDNR", OracleType.NVarChar).Value = dwData["VAKBKUNDNR"].ToString();
                    break;
                default:
                    break;
            }
            Connect2Proxy(or1);
        }

        public void UpdateWPACK(DataRow dwData, string ITXDBVERSION = "50.24", int option = 1)
        {

            or1 = OracleDB.CreateCommand();
            if (option == 0)
            {
                switch (app.company)
                {
                    case "YGR":
                    case "YCC":
                    default:
                        option = 1;
                        break;
                    case "JLT":
                        option = 2;
                        break;
                }
            }
            switch (option)
            {
                case 1:
                    #region====Command====
                    or1.CommandText = "UPDATE WPACK SET WPMANDANT=:WPMANDANT:,WPLIEFSCH=:WPLIEFSCH:,WPPACKNR=:WPPACKNR:,WPPACKPOS=:WPPACKPOS:,WPAUFTYP=:WPAUFTYP:,WPAUFKRS=:WPAUFKRS:,WPAUFLFD=:WPAUFLFD:,WPAUFPOS=:WPAUFPOS:,WPTEILNR=:WPTEILNR:,WPRWKRS=:WPRWKRS:,WPRWLFD=:WPRWLFD:,WPPOS=:WPPOS:,WPLO=:WPLO:,WPLB=:WPLB:,WPAUFBKZ=:WPAUFBKZ:,WPDPART=:WPDPART:,WPDPART2=:WPDPART2:,WPSTKNR=:WPSTKNR:,WPKUNDNR=:WPKUNDNR:,WPWERK=:WPWERK:,WPABT=:WPABT:,WPWAKZ=:WPWAKZ:,WPART=:WPART:,WPVAR=:WPVAR:,WPDESS=:WPDESS:,WPCOLORIT=:WPCOLORIT:,WPFARBE=:WPFARBE:,WPBESCHICH=:WPBESCHICH:,WPZUSTAND=:WPZUSTAND:,WPFARBN=:WPFARBN:,WPISTKLG=:WPISTKLG:,WPIGEW=:WPIGEW:,WPIBRT=:WPIBRT:,WPBRGEW=:WPBRGEW:,WPDM=:WPDM:,WPVOL=:WPVOL:,WPIGEWKZ=:WPIGEWKZ:,WPIANZ=:WPIANZ:,WPMABRT1=:WPMABRT1:,WPMASTKL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HBRT5:,WPSHSTKLG5=:WPSHSTKLG5:,WPSTKNRK=:WPSTKNRK:,WPAUSFFRB=:WPAUSFFRB:,WPAUSFGRI=:WPAUSFGRI:,WPAUSFQUAL=:WPAUSFQUAL:,WPQUALST=:WPQUALST:,WPQPKT=:WPQPKT:,WPQPKTH=:WPQPKTH:,WPQPKTL=:WPQPKTL:,WPQPKTLH=:WPQPKTLH:,WPISTKLGFA=:WPISTKLGFA:,WPISTKLGF=:WPISTKLGF:,WPFRTWSKZ=:WPFRTWSKZ:,WPLTPOS=:WPLTPOS:,WPILGFBT=:WPILGFBT:,WPILGRBT=:WPILGRBT:,WPIBRTFV=:WPIBRTFV:,WPIBRTFB=:WPIBRTFB:,WPFEUCHTE=:WPFEUCHTE:,WPKDPART=:WPKDPART:,WPBEM=:WPBEM:,WPTXSCHL=:WPTXSCHL:,WPREFSCHL=:WPREFSCHL:,WPRSFSCHL=:WPRSFSCHL:,WPVEFSCHL=:WPVEFSCHL:,WPVSFSCHL=:WPVSFSCHL:,WPRAMPE=:WPRAMPE:,WPFILLER=:WPFILLER:,WPAENZL=:WPAENZL:,WPNEUB=:WPNEUB:,WPNEUD=:WPNEUD:,WPAENB=:WPAENB:,WPAEND=:WPAEND:"
                        + " WHERE WPMANDANT=:WPMANDANT: AND  WPLIEFSCH=:WPLIEFSCH: AND WPPACKNR=:WPPACKNR: AND WPPACKPOS=:WPPACKPOS: ";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    #endregion
                    break;
                case 2:
                    #region====Command====
                    or1.CommandText = "UPDATE WPACK SET WPMANDANT=:WPMANDANT:,WPLIEFSCH=:WPLIEFSCH:,WPPACKNR=:WPPACKNR:,WPPACKPOS=:WPPACKPOS:,WPAUFTYP=:WPAUFTYP:,WPAUFKRS=:WPAUFKRS:,WPAUFLFD=:WPAUFLFD:,WPAUFPOS=:WPAUFPOS:,WPTEILNR=:WPTEILNR:,WPRWKRS=:WPRWKRS:,WPRWLFD=:WPRWLFD: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L=:WPAENZL:,WPNEUB=:WPNEUB:,WPNEUD=:WPNEUD:,WPAENB=:WPAENB:,WPAEND=:WPAEND:"
                        + " WHERE WPMANDANT=:WPMANDANT: AND  WPLIEFSCH=:WPLIEFSCH: AND WPPACKNR=:WPPACKNR: AND WPPACKPOS=:WPPACKPOS: ";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    #endregion
                    break;
                default:
                    break;
            }
            Connect2Proxy(or1);
        }
    }
}
